package com.restaurant.application.shoplist.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class ShopListPageVo implements PickableBean {

    public static final String FN_ID = "id";
    public static final String FN_NAME = "name";
    public static final String FN_PHONE = "phone";
    public static final String FN_MAIL = "mail";
    public static final String FN_ADDRESS = "address";
    public static final String FN_SEQ = "seq";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_ID,
            FN_NAME,
            FN_PHONE,
            FN_MAIL,
            FN_ADDRESS,
            FN_SEQ);

    private String id;
    private String name;
    private String phone;
    private String mail;
    private String address;
    private Long seq;

    public ShopListPageVo(String id, String name, String phone, String mail, String address, Long seq) {
        setId(id);
        setName(name);
        setPhone(phone);
        setMail(mail);
        setAddress(address);
        setSeq(seq);
    }

    public ShopListPageVo() {
    }

    public ShopListPageVo duplicate() {
        ShopListPageVo result = new ShopListPageVo();
        result.id = this.id;
        result.name = this.name;
        result.phone = this.phone;
        result.mail = this.mail;
        result.address = this.address;
        result.seq = this.seq;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getId() {
        return id;
    }

    public void setId(String value) {
        this.id = value;
    }

    public ShopListPageVo withId(String value) {
        setId(value);
        return this;
    }

    public ShopListPageVo withId(String value, String defaultValue) {
        setId(value == null ? defaultValue : value);
        return this;
    }
    
    public String getName() {
        return name;
    }

    public void setName(String value) {
        this.name = value;
    }

    public ShopListPageVo withName(String value) {
        setName(value);
        return this;
    }

    public ShopListPageVo withName(String value, String defaultValue) {
        setName(value == null ? defaultValue : value);
        return this;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String value) {
        this.phone = value;
    }

    public ShopListPageVo withPhone(String value) {
        setPhone(value);
        return this;
    }

    public ShopListPageVo withPhone(String value, String defaultValue) {
        setPhone(value == null ? defaultValue : value);
        return this;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String value) {
        this.mail = value;
    }

    public ShopListPageVo withMail(String value) {
        setMail(value);
        return this;
    }

    public ShopListPageVo withMail(String value, String defaultValue) {
        setMail(value == null ? defaultValue : value);
        return this;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String value) {
        this.address = value;
    }

    public ShopListPageVo withAddress(String value) {
        setAddress(value);
        return this;
    }

    public ShopListPageVo withAddress(String value, String defaultValue) {
        setAddress(value == null ? defaultValue : value);
        return this;
    }

    public Long getSeq() {
        return seq;
    }

    public void setSeq(Long value) {
        this.seq = value;
    }

    public ShopListPageVo withSeq(Long value) {
        setSeq(value);
        return this;
    }

    public ShopListPageVo withSeq(Long value, Long defaultValue) {
        setSeq(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "id":
                return getId();
            case "name":
                return getName();
            case "phone":
                return getPhone();
            case "mail":
                return getMail();
            case "address":
                return getAddress();
            case "seq":
                return getSeq();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof ShopListPageVo)) return false;
        return signature().equals(((ShopListPageVo) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean ShopListPageVo has no signature defined, no hash code or equals possible.");
    }
}
